<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" th:href="@{~/layui/css/layui.css}">
		<script th:src="@{~/layui/layui.js}"></script>
		<title>Admin</title>
	</head>
	<body class="layui-layout-body">
		<div class="layui-layout layui-layout-admin">
			<div class="layui-header">
				<div class="layui-logo">云社区</div>
				<ul class="layui-nav layui-layout-right">
					<li class="layui-nav-item" sec:authentication="name">
						清风随我意
					</li>
					<li class="layui-nav-item"><a th:href="@{~/logout}">退出</a></li>
				</ul>
			</div>
			<div class="layui-side layui-bg-black">
				<div class="layui-side-scroll">
					<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
					<ul class="layui-nav layui-nav-tree" lay-filter="test" lay-shrink="all">
						<li class="layui-nav-item"><a href="index">首页</a></li>
						<li class="layui-nav-item"><a href="user">用户管理</a></li>
						<li class="layui-nav-item">
							<a href="javascript:;">资源管理</a>
							<dl class="layui-nav-child">
								<dd><a href="wapTj">审核资源</a></dd>
								<dd><a href="wapList">资源列表</a></dd>
							</dl>
						</li>
						<li class="layui-nav-item"><a href="">设置</a></li>
					</ul>
				</div>
			</div>
			<div class="layui-body" style="background-color: #F2F2F2;">
				<div class="layui-fluid">
					<div class="layui-row layui-col-space15" style="padding-top: 20px;">
						<div class="layui-card">
							<div class="layui-card-header">
								<span class="layui-breadcrumb">
									<a href="">资源管理</a>
									<a><cite>资源列表</cite></a>
								</span>
							</div>
							<div class="layui-card-body">
								<table id="user-data" lay-filter="test" ></table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-footer">
				<div class="layui-main">
					<p align="center">@2019 <a th:href="@{http://www.yqfeng.xyz}">www.yqfeng.com</a> ---云社区</p>
				</div>
			</div>
		</div>
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		</script>
		<script>
			layui.use('element', function() {
				var element = layui.element;
			});
			layui.use(['table','jquery'], function() {
				var table = layui.table,
					$=layui.jquery;

				//第一个实例
				table.render({
					elem: '#user-data',

					url: '/admin/wapData', //数据接口,
					limit:17,
					limits:[17,30,45,60],
					page: true ,//开启分页,
					cellMinWidth: 80,
					cols: [
						[ //表头
							{
								field: 'id',
								title: 'ID',
								fixed: 'left',
								width: 100
							}, {
								field: 'name',
								title: '资源名称',
								width:250

							}, {
								field: 'www',
								title: '资源链接',

							}, {
								field: 'password',
								title: '资源密码',
								width: 100
							}, {
								field: 'count',
								title: '点击数',
								sort: true,
								width: 100
							}, {
								field: 'statusStr',
								title: '状态',
								width: 100
							}, {
								field: 'upload',
								title: '上传者',
								width: 200,
								align:"center"
							}, {
								field: 'typeStr',
								title: '资源类型',
								width: 100
							}, {
								fixed: 'right',
								title:'操作',
								toolbar: '#barDemo',
								width:100,
								align:"center"
							}
						]
					]
				});
				table.on('tool(test)', function(obj){
					var data = obj.data;
					if(obj.event === 'del'){
						layer.confirm('要删除该资源吗?',{'title':"警告"}, function(index){
							$.ajax({
								url:"/admin/del?id="+data.id,
								success:function () {
									layer.msg("删除成功.");
									obj.del();
								}
							});
							layer.close(index);
						});
					}
				});
			});
		</script>
	</body>
</html>
